Answer:

It is rounded to 2.0 (or 2,0 depending on your locale).

Wrapper Class Output

Recall (from the end of chapter 9C) that a wrapper class defines objects that each hold a primitive value. For example, objects of class Integer each hold one int (and some methods for manipulating ints). A wrapper object may be used as data for format(). Here is a program that shows this:

import java.text.*;

class IODemoWrapper
{
  public static void main ( String[] args )
  {
    Integer i = new Integer( 7654321 );
    Double  d = new Double ( 11000.0008 );
    
    DecimalFormat numform = new DecimalFormat(); 
    
    System.out.println( "integer = " + numform.format(i) + " double = " + numform.format(d) );
  }
}

The output of the program is (for a computer in the US):

integer = 7,654,321 double = 11,000.001

Again, the locale of your computer will affect the format. Also, notice that the output for the double is rounded.

QUESTION 7:

Has the contents of the variable value been changed by format()?